<template>
  <el-upload :show-file-list="false" :on-success="success" class="upload-button">
    <simple-button
      :plain="plain"
      :round="round"
      :circle="circle"
      :confirm="confirm"
      :size="size"
      :face="face"
      :icon="icon"
      :label="btn || label || '提交'"
    />
  </el-upload>
</template>

<script lang="ts" setup>
  /**
   * 文件上传按钮
   *    props: { url: 上传地址,  el-upload: el-upload-props }
   *    @click 上传完成钩子
   */

  import { ElUpload } from 'element-plus';
  import { Confirm } from '../../button/button';
  import { Face, Icon, Size } from '../../elementUI';
  import SimpleButton from '../../button/SimpleButton.vue';

  const emit = defineEmits(['update:modelValue']);

  defineProps<{
    plain?: boolean;
    round?: boolean;
    circle?: boolean;
    confirm?: Confirm;
    face?: Face;
    icon?: Icon;
    size?: Size;

    label?: string;
    btn?: string;
    modelValue?: string;
  }>();
  function success(response: string) {
    emit('update:modelValue', response);
  }
</script>

<style scoped>
  .upload-button {
    display: inline-block;
  }
</style>
